package com.ruoyi.biz.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.biz.mapper.BizProjectMapper;
import com.ruoyi.biz.model.req.*;
import com.ruoyi.biz.model.resp.CostProjectResp;
import com.ruoyi.biz.model.resp.InvoiceProjectResp;
import com.ruoyi.biz.model.resp.ReceiptProjectResp;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.PageUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.ruoyi.common.utils.SecurityUtils.getUserId;


/**
 * 项目信息Service业务层处理
 *
 * @author tianl
 * @date 2024-12-20
 */
@Slf4j
@Service
public class ProjectQueryService {
    @Autowired
    private BizProjectMapper bizProjectMapper;

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public IPage<InvoiceProjectResp> listInvoice(InvoiceProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listInvoice(PageUtils.page(), req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public List<InvoiceProjectResp> listAllInvoice(InvoiceProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listInvoice(req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public IPage<ReceiptProjectResp> listReceipt(ReceiptProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listReceipt(PageUtils.page(), req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public List<ReceiptProjectResp> listAllReceipt(ReceiptProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listReceipt(req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public IPage<CostProjectResp> listCost(CostProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listCost(PageUtils.page(), req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public List<CostProjectResp> listAllCost(CostProjectReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listCost(req);
    }

    @DataScope(userAlias = "t", deptAlias = "t", enforceAlias = "t")
    public List<Long> listProjectId(ProjectQueryReq req) {
        req.getParams().put("userId", getUserId());
        return bizProjectMapper.listProjectId(req);
    }

}
